***********************
**** ALL PANELS *******
***********************
clear all
set more off
cd "/Users/yasenov/Dropbox/mariel_boatlift/jhr_version/jhr_figures"
global folder /Users/yasenov/Dropbox/mariel_boatlift/revision_version/revision_data/
set scheme s1color

use $folder/aux_nonevent.dta

keep if logearnwke != .
keep if ethnic != 5 
keep if low_skilled == 1
drop if ftpt79 == 0 | ftpt89 == 1 | ftpt94 == 1
drop if classer > 2 & classer != . & year <= 1993
drop if class94 > 4 & class94 !=. & year >= 1994

sort msafips year // delete msafipss with too few observations
by msafips year: gen sum_year = _N
by msafips: egen min_year = min(sum_year)
drop if min_year < 20		// # min obs per msafips-year
drop sum_year min_year

collapse (mean) loguearnhre logearnwke (p15) p15loguearnhre = loguearnhre ///
	 p15logearnwke = logearnwke [pw=earnwt], by(year msafips)

merge 1:1 msafips year using $folder/msa_controls_nonevent, nogenerate
drop if logearnwke == .

sort msafips year
by msafips: gen num_year = _N
tab num_year
keep if num_year >= 14 
keep if year > 1988
xtset msafips year
label drop _all

global controls loguearnhre(1990) loguearnhre(1993) low_skilled hisp manuf
synth loguearnhre $controls, trunit(5000) trperiod(1994) nested keep(fig10a.dta, replace)

global controls logearnwke(1990) logearnwke(1993) low_skilled hisp manuf
synth logearnwke $controls, trunit(5000) trperiod(1994) nested keep(fig10b.dta, replace)

global controls p15loguearnhre(1990) p15loguearnhre(1993) low_skilled hisp manuf
synth p15loguearnhre $controls, trunit(5000) trperiod(1994) nested keep(fig10c.dta,replace)

global controls p15logearnwke(1990) p15logearnwke(1993) low_skilled hisp manuf
synth p15logearnwke $controls, trunit(5000) trperiod(1994) nested keep(fig10d.dta,replace)

use fig10a.dta, clear
rename (_time _Y_t _Y_s) (year miami synthetic)
keep year miami synthetic
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xtitle("") ///
	ytitle("") ///
	xline(1993, lcolor(black) lpattern(dash)) ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("Mean Log Hourly Wages") ///
	xlabel(1989 "1989" 1991 "91" 1993 `""93" "Pre""' 1995 `""95" "Post""' 1997 "97" 1999 "99" 2001 "01") ///
	xscale(range(1989 2002)) ///
	ylabel(1.65(.1)2.05) ///
	text(1.65 2001 "Panel A")  nodraw  plotregion(lwidth(none))

graph copy one, replace

use fig10b.dta, clear
rename (_time _Y_t _Y_s) (year miami synthetic)
keep year miami synthetic
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xtitle("") ///
	ytitle("") ///
	xline(1993, lcolor(black) lpattern(dash)) ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("Mean Log Weekly Wages") ///
	xlabel(1989 "1989" 1991 "91" 1993 `""93" "Pre""' 1995 `""95" "Post""' 1997 "97" 1999 "99" 2001 "01") ///
	ylabel(5.15(.2)5.75) ///
	text(5.15 2001 "Panel B")  nodraw  plotregion(lwidth(none))

graph copy two, replace

use fig10c.dta, clear
rename (_time _Y_t _Y_s) (year miami synthetic)
keep year miami synthetic
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xtitle("") ///
	ytitle("") ///
	xline(1993, lcolor(black) lpattern(dash)) ///
	legend(label(1 "Miami") label(2 "Synthetic Miami")) ///
	subtitle("15th Percentile Log Hourly Wages") ///
	xlabel(1989 "1989" 1991 "91" 1993 `""93" "Pre""' 1995 `""95" "Post""' 1997 "97" 1999 "99" 2001 "01") ///
	xscale(range(1989 2002)) ///
	ylabel(1.3(.1)1.7)  ///
	text(1.3 2001 "Panel C")  nodraw  plotregion(lwidth(none))

graph copy three, replace

use fig10d.dta, clear
rename (_time _Y_t _Y_s) (year miami synthetic)
keep year miami synthetic
keep if year != .
twoway (line miami year, lcolor(black) lpattern(solid)) ///
	(line synthetic year, lcolor(black) lpattern(dash)), ///
	xtitle("") ///
	ytitle("") ///
	xline(1993, lcolor(black) lpattern(dash)) ///
	legend(label(1 "Miami") label(2 "Synthetic Miami") size(small)) ///
	subtitle("15th Percentile Log Weekly Wages") ///
	xlabel(1989 "1989" 1991 "91" 1993 `""93" "Pre""' 1995 `""95" "Post""' 1997 "97" 1999 "99" 2001 "01") ///
	xscale(range(1989 2002)) ///
	ylabel(4.4(.2)5.2) ///
	text(4.4 2001 "Panel D") plotregion(lwidth(none))

graph copy four, replace
grc1leg one two three four, imargin(vsmall)  legendfrom(four)
graph export "jhr_fig10.pdf", replace
